package com.bms.hystrix.controller.jxgl;

import com.bms.hystrix.pojo.YiWuRenYuanVo;
import com.bms.hystrix.service.jxgl.CheckService;
import io.swagger.annotations.*;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author zhangyujin
 * @version 1.0
 * @description CheckController.java
 * @date 2021/3/22 10:06
 */
@RestController
@RequestMapping("yiWuRenYuan")
@Api(value = "(YiWuRenYuan)管理", tags = "(YiWuRenYuan)管理接口API")
@ApiResponses({
        @ApiResponse(code = 400, message = "请求参数不完整或者错误"),
        @ApiResponse(code = 404, message = "找不到页面"),
        @ApiResponse(code = 405, message = "请求方式不正确，比如后台接收是post，但前端请求的是get"),
        @ApiResponse(code = 406, message = "页面地址和接口名冲突"),
        @ApiResponse(code = 415, message = "请求格式不正确，前端可能没有把请求头修改为json，也可能前端请求的json对象没有转换为字符串"),
        @ApiResponse(code = 500, message = "后台服务逻辑错误")
})
public class CheckController {
    @Resource
    private CheckService checkService;
    /*
    这里类似于ribbon，提供一个对外访问的接口地址，
    然后根据serviceFeignByCheck接口来决定调用哪一个子模块服务和哪一个接口地址
     */
    @RequestMapping(value = "/chaXunById",method = RequestMethod.GET)
//            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)

    public Map check(String id) {
        return checkService.check(id);
    }



    @RequestMapping(value = "/chaXunFenYe", method = RequestMethod.GET)
//            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "列表查询分页接口", notes = "列表查询分页接口", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码", paramType = "query", dataType = "String", required = false),
            @ApiImplicitParam(name = "mingCheng", value = "**名称", paramType = "query", dataType = "String", required = false)
    })
    public Map chaXunFenYe(Integer page, String mingCheng) {
       System.out.println(page+mingCheng);
        return checkService.chaXunFenYe(page,mingCheng);
    }

    @RequestMapping(value = "xinZeng", method = RequestMethod.POST)
//            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Map xinZeng(@RequestBody YiWuRenYuanVo yiWuRenYuan){
        System.out.println(yiWuRenYuan.toString());
        return checkService.xinZeng(yiWuRenYuan);
    }

    @RequestMapping(value = "chaxXunByTiaoJian", method = RequestMethod.GET)
//            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Map<String, Object> chaxXunByTiaoJian(String name,Integer page,Integer limit) {
        return this.checkService.chaxXunByTiaoJian(name,page,limit);
    }
}
